package com.ruitu.mall_98_1.mvp.presenter;

import com.beanu.arad.utils.ToastUtils;
import com.ruitu.mall_98_1.mvp.contract.ProListByModelContract;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.api.PageModel;
import com.ruitu.router_module.bean.api.SubscriberImpl;
import com.ruitu.router_module.bean.product.ProList;

/**
 * Created by Administrator on 2018/11/05
 */
public class ProListByModelPresenterImpl extends ProListByModelContract.Presenter {

    @Override
    public void reqProList(String type, String cityName, String keys, int page, int size) {
        mModel.reqProList(type, cityName, keys, page, size).subscribe(new SubscriberImpl<BaseResult<PageModel<ProList>>>() {
            @Override
            public void onError(Throwable e) {
                mView.hideProgress();
                e.printStackTrace();
            }

            @Override
            public void onNext(BaseResult<PageModel<ProList>> pageResult) {
                mView.hideProgress();
                if (pageResult.isSuccess()) {
                    mView.onReqComlete(true, 1, pageResult.getData());
                } else {
                    ToastUtils.showShort(pageResult.getMsg());
                }
            }
        });
    }
}